home *** CD-ROM | disk | FTP | other *** search
Modula Definition | 1997-05-14 | 2.7 KB | 81 lines | [TEXT/3PRM] |
- definition module types
-
-
- import StdString, StdClass, StdFile
-
-
- /***************************************************************************************************************
- Basic type definitions.
- ****************************************************************************************************************/
- :: Playmode = EndPlayer1 | EndPlayer2 | Playing
- :: Playerkind = Computer | Person
- :: Player = Player1 | Player2
- :: Strength = Maximum | First | Strength Real
- :: Direction = Hor | Ver
- :: Word :== String
- :: Position :== (!Int,!Int)
-
- MediumStrength :== Strength 0.5
- EasyStrength :== Strength 0.25
- VeryEasyStrength :== Strength 0.125
-
- instance == Playmode
- instance == Playerkind
- instance == Player
- instance == Strength
- instance == Direction
- instance == Placing
-
- otherplayer :: !Player -> Player
-
-
- /***************************************************************************************************************
- The type Progress is by the computer player function when determining a move. The computer player checks in
- alfabetic order all words starting with a particular letter.
-
- Words starting with a particular letter are handled quickly when the starting letter does not occur on the
- letter bar. In that case the positions on the board are checked if they are valid as a starting position for
- the word (horizontal and vertical are handled separately).
-
- For words starting with a particular letter on the letter bar more board positions need to be examined.
- ****************************************************************************************************************/
- :: Progress
- = Letter Char Placing
- | Finish Placing
- :: Placing
- = { word :: Word
- , pos :: Position
- , dir :: Direction
- , score :: Int
- }
- initplacing :: Placing
- getplacing :: !Progress -> Placing
- getletter :: !Progress -> Char
- notyetready :: !Progress -> Bool
-
-
- /***************************************************************************************************************
- The Tree type stores the lexicon.
- ****************************************************************************************************************/
-
- :: Tree
- = Leaf !String
- | Node Tree !String Tree
-
- readtree :: !Files -> (!Tree,!Files)
- writetree :: !Tree !Files -> Files
- wordsstartingwith :: !Char !Tree -> [Word]
- seek :: !Tree !String -> Bool
- sizetree :: !Tree -> Int
- depthtree :: !Tree -> Int
- addwordstotree :: !Tree ![Word] -> Tree
-
-
- /***************************************************************************************************************
- Global Ids.
- ****************************************************************************************************************/
-
- scrabbleId :== 1
- toevoegId :== 2
- computerId :== 1
-